<template>
	<view class="">
		<fa-navbar title=" " :border-bottom="false"></fa-navbar>
		<view class="bg"></view>
		<!-- <image src="/static/image/index_search.jpg" mode="widthFix" style="width: 100%;"></image> -->
		<image :src="sucai['index_search']" mode="widthFix" style="width: 100%;"
			@click="goPage('/pages/search/search?status=1', true)"></image>

		<view class="top_btn_group">
			<view class="top_btn_item" >
				<image :src="banar[0]" mode="widthFix" class="index_top_icon"></image>
				<view class="top_title">
					破土设计
				</view>
				<view class="top_name">
					(设计商城)
				</view>
			</view>
			<view class="top_btn_item" @click="goPage('/pages/index/index', true)">
				<image :src="banar[1]" mode="widthFix" class="index_top_icon"></image>
				<view class="top_title">
					破土森林
				</view>
				<view class="top_name">
					(美学社区)
				</view>
			</view>
			<view class="top_btn_item" @click="goPage('/pages/index/secondIndex?status=1', true)">
				<image :src="banar[2]" mode="widthFix" class="index_top_icon"></image>
				<view class="top_title">
					破土计划
				</view>
				<view class="top_name">
					(公益与教育)
				</view>
			</view>
		</view>

		<view class="">
			<u-swiper height="1000" :list="vuex_config.swiper"
			@click="openPage"></u-swiper>
		</view>
		<!-- /pages/goods/goods?category_id=1 -->
		<!-- 中间魔方图片 -->
		<view class="" style="display: flex;justify-content: space-around;padding-top: 120rpx;">
			<view class="" style="width: 400rpx;">
				<image :src="cate[0]['image']" mode="aspectFill" style="width: 100%;height: 540rpx;"
					@click="goPage('/pages/goods/goods?category_id=' + cate[0]['id'])"></image>
			</view>
			<view class="" style="width: 588rpx">
				<image :src="cate[1]['image']" mode="aspectFill" style="width: 100%;height: 267rpx;"
					@click="goPage('/pages/goods/goods?category_id=' +cate[1]['id'])"></image>
				<view class="" style="display: flex; justify-content: space-around;">
					<image :src="cate[2]['image']" mode="aspectFill" style="width: 48%;height: 265rpx;"
						@click="goPage('/pages/goods/goods?category_id=' + cate[2]['id'])">
					</image>
					<image :src="cate[3]['image']" mode="aspectFill" style="width: 48%;height: 265rpx;"
						@click="goPage('/pages/goods/goods?category_id=' + cate[3]['id'])">
					</image>
				</view>
			</view>
		</view>
			<!-- <image src="sucai['index_search']" mode="widthFix" style="width: 100%;" -->
		<view class="">
			<image :src="sucai['shop_quan']" mode="widthFix" style="width: 100%;"></image>
		</view>

		<view class="">
			<image src="/static/image/index_title.jpg" mode="widthFix" style="width: 100%;"></image>
		</view>

		<view class="index_new">
			<!-- <image src="/static/image/index_bg1.jpg" mode="widthFix" class="index_bg"></image> -->
			<image :src="sucai['index_bg1']" mode="widthFix" class="index_bg"></image>

			<view class="goods-list " style="overflow: auto;flex-wrap: inherit;">
				<view class="item" style="margin-right: 20rpx;" v-for="(item, index) in recommends" :key="index"
					v-if="index < 20" @click="goPage('/pages/goods/detail?id=' + item.id)">
					<view class="images">
						<image :src="item.image" mode="aspectFill"></image>
					</view>
					<view class="u-p-15 name">
						<text class="u-line-2">{{ item.title }}</text>
					</view>
					<view class="foot u-flex u-row-between u-tips-color">
						<view class="">
							<text class="u-m-r-10">销量</text>
							<text>{{ item.sales }}</text>
						</view>
						<view class="">
							<text>{{ item.storename }}</text>
						</view>
					</view>
					<view class="u-flex u-row-between u-p-15">
						<view class="price">
							<text>￥{{ item.price }}</text>
						</view>
						<text class="market_price u-tips-color">￥{{ item.marketprice }}</text>
					</view>
				</view>

			</view>
		</view>


		<view class="">
			<image src="/static/image/index_title1.jpg" mode="widthFix" style="width: 100%;"></image>
		</view>
		<view class="">
			<view class="goods-list" style="padding-top: 0;">
				<view class="item" v-for="(item, index) in news" :key="index"
					@click="goPage('/pages/goods/detail?id=' + item.id)">
					<view class="images">
						<image :src="item.image" mode="aspectFill"></image>
					</view>
					<view class="u-p-15 name">
						<text class="u-line-2">{{ item.title }}</text>
					</view>
					<view class="foot u-flex u-row-between u-tips-color">
						<view class="">
							<text class="u-m-r-10">销量</text>
							<text>{{ item.sales }}</text>
						</view>
						<view class="">
							<text>{{ item.storename }}</text>
						</view>
					</view>
					<view class="u-flex u-row-between u-p-15">
						<view class="price">
							<text>￥{{ item.price }}</text>
						</view>
						<text class="market_price u-tips-color">￥{{ item.marketprice }}</text>
					</view>
				</view>

			</view>
		</view>

		<!-- 士大夫士大夫士大夫 -->

		<fa-tabbar :visible="true"></fa-tabbar>

	</view>
</template>

<script>
	export default {


		data() {
			return {
				keyword: '',

				background: {
					backgroundColor: "transparent",
				},
				banar: [],
				list: [
					// 	{
					// 	image: require('@/static/image/login_bg.jpg'),
					// }, 

				],
				recommends: [],
				news: [],
				cate: [],
				sucai: []
			}
		},
		onLoad() {
			// this.handleLoad()



			this.getVideo()
			this.getGoodsIndex();
			// this.getpublicArticleList();


		},

		onShow() {

		},
		created() {

		},
		onReachBottom(e) {

		},
		methods: {
			getVideo() {
				this.$api.indexShow({}).then(res => {
					console.log(res)
					if (res.code == 1) {
						this.banar = res.data.banar;
						this.cate = res.data.catelist;
						this.sucai = res.data.sucai;

					}
				})
			},
			getGoodsIndex() {
				this.$api.getGoodsIndex().then(({
					code,
					data: res,
					msg
				}) => {
					if (code) {
						console.log(1111111111, res)
						this.recommends = res.recommends;
						this.news = res.news;

					}
				});
			},


			todetail() {
				uni.navigateTo({
					url: '/sub_pages/donation/donation'
				})
			},
			todetailBtn2() {
				uni.navigateTo({
					url: '/sub_pages/donation/donation'
				})
			},
			todetailBtn3() {
				uni.navigateTo({
					url: '/sub_pages/donation/donation'
				})
			},
			
				grids(e) {
							let path = e.path;
							if (path == '/' || !path) {
								return;
							}
							if (path.substr(0, 1) == 'p') {
								path = '/' + path;
							}
							if (path.includes('http')) {
								this.$u.vuex('vuex_webs', {
									path: e.path,
									title: e.name
								});
								this.$u.route('/pages/webview/webview');
								return;
							}
							this.$u.route(path);
				},
				openPage(index) {
							console.log("跳转，，，，");
										this.grids({
											path: this.vuex_config.swiper[index].url,
											name: this.vuex_config.swiper[index].title
										});
				},
				click(index) {
							if (this.vuex_config.notice) {
									let url = this.vuex_config.notice[index].path;
									if (url) {
												this.grids({
													path: url,
													name: this.vuex_config.notice[index].title
												});
											}
										}
				}
			


		},
	}
</script>
<style lang="scss">
	page {
		background-color: #f7faeb;
	}
</style>

<style lang="less" scoped>
	.top_btn_group {
		display: flex;
		align-items: flex-end;

		.top_btn_item {
			width: 33.33%;
			text-align: center;

			.index_top_icon {
				width: 196rpx;
			}

			.top_title {
				font-weight: 400;
				font-size: 32rpx;
				color: #529030;
				line-height: 44rpx;
				text-align: center;
				font-style: normal;
				text-transform: none
			}

			.top_name {
				font-weight: 600;
				font-size: 16rpx;
				color: rgba(51, 51, 51, 0.4);
				line-height: 44rpx;
				text-align: center;
				font-style: normal;
				text-transform: none;
			}
		}
	}

	.index_img1 {
		width: 100%;
		border-radius: 20rpx;
	}

	.img_group {
		display: flex;
		padding: 24rpx;

		.img_item {
			width: 50%;
			margin: 0 10rpx;
		}

		.index_img2 {
			width: 100%;
			height: 540rpx;
			border-radius: 14rpx;
		}

		.index_img3 {
			width: 100%;
			height: 48%;
			border-radius: 14rpx;
			// margin: 20rpx;
		}
	}


	.btn_group {
		padding: 24rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;

		.btn_item {
			width: 33.33%;
			text-align: center;

			.btn_title {
				background-color: #649142;
				border-radius: 50%;
				padding: 20rpx;
				color: #fff;
				font-size: 40rpx;
				font-weight: bold;
				margin: 10rpx;
			}
		}
	}

	.btn_1 {
		width: 120rpx;
		height: 120rpx;
		background-color: transparent;
		position: absolute;
		left: 110rpx;
		top: 120rpx;
		z-index: 1;
	}

	.btn_2 {
		width: 120rpx;
		height: 120rpx;
		background-color: transparent;
		position: absolute;
		left: 312rpx;
		top: 120rpx;
		z-index: 1;
	}

	.btn_3 {
		width: 120rpx;
		height: 120rpx;
		background-color: transparent;
		position: absolute;
		right: 110rpx;
		top: 120rpx;
		z-index: 1;
	}

	.index_new {
		padding: 0 24rpx;
		// position: relative;
	}

	.index_bg {
		width: 96%;
		border-radius: 30rpx;
		position: absolute;
		margin: 0 auto;
		left: 0;
		right: 0;

		z-index: -1;
	}


	.goods-list {
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		// margin-top: 30rpx;
		padding: 0 30rpx;
		padding-top: 400rpx;



		.item {
			width: calc((100vw - 126rpx) / 2);
			background-color: #ffffff;
			box-shadow: 0px 0px 5px rgb(233, 235, 243);
			margin-bottom: 30rpx;
			border-radius: 10rpx;
			overflow: hidden;
			border: 1px solid #e9ebf3;
			flex-shrink: 0;

			.name {
				min-height: 110rpx;
			}

			.foot {
				padding: 0 15rpx;
			}

			.images {
				width: 100%;
				height: 350rpx;

				image {
					width: 100%;
					height: 100%;
				}
			}

			.market_price {
				text-decoration: line-through;
				margin-left: 10rpx;
			}
		}
	}

	.hots-list {
		margin-top: 30rpx;
		padding: 0 30rpx 30rpx;

		.item {
			width: 100%;
			background-color: #ffffff;
			box-shadow: 0px 0px 5px rgb(233, 235, 243);
			margin-bottom: 30rpx;
			border-radius: 10rpx;
			overflow: hidden;
			border: 1px solid #e9ebf3;
			display: flex;
			justify-content: space-between;
			align-items: center;

			.images {
				width: 250rpx;
				height: 220rpx;

				image {
					width: 100%;
					height: 100%;
				}
			}

			.content {
				flex: 1;

				.name {
					min-height: 110rpx;
				}

				.foot {
					padding: 0 15rpx;
				}

				.market_price {
					text-decoration: line-through;
					margin-left: 10rpx;
				}
			}
		}
	}
</style>